from time import sleep
from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction 

desired_capabilities = {
  "platformName": "Android",
  "platformVersion": "5.1.1",
  "deviceName": "62002"
}

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_capabilities=desired_capabilities)

# 打开百度文库
driver.find_element_by_accessibility_id('百度文库').click()
sleep(10)
# 按下 Home键
driver.press_keycode(3)

# 按下音量键
driver.long_press_keycode(24)
sleep(10)
driver.long_press_keycode(25)